package com.lp.batch.domain;

import java.util.ArrayList;
import java.util.List;

/**
 * A class intended to map a taxonomies element
 * 
 * @author Zainul Franciscus
 * 
 */
public class Taxonomies implements java.io.Serializable {

	/**
	 * A top level element in a taxonomy.xml
	 */
	private Taxonomy taxonomy;

	/**
	 * @return the taxonomy
	 */
	public Taxonomy getTaxonomy() {
		return taxonomy;
	}

	/**
	 * @param taxonomy
	 *            the taxonomy to set
	 */
	public void setTaxonomy(Taxonomy taxonomy) {
		this.taxonomy = taxonomy;
	}

	/**
	 * @return the number of destinations in this taxonomy.
	 */
	public int countDestinations() {
		return taxonomy.getChildNodes().size();
	}

	/**
	 * Each destination can have more than 1 sub-destinations. This method does
	 * not return those sub-destinations.
	 * 
	 * @return return destinations from a taxonomy.
	 */
	public List<Node> getDestinations() {
		return taxonomy.getChildNodes();
	}
	
	/**
	 * @return all destinations in this taxonomies
	 */
	public List<Node> getAllDestinations(){
		List<Node> nodes = new ArrayList<Node>();
		for(Node node: taxonomy.getChildNodes()){
			nodes.addAll(node.getAllNodes());
		}
		
		return nodes;
	}

}
